/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.tom.social.dal.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Tom
 */
@Entity
@Table(name = "Analysis_TermResult")
@NamedQueries({@NamedQuery(name = "AnalysisTermResult.findAll", query = "SELECT a FROM AnalysisTermResult a")})
public class AnalysisTermResult implements Serializable {
	private static final long serialVersionUID = 1L;
	@EmbeddedId
	protected AnalysisTermResultPK analysisTermResultPK;
	@Basic(optional = false)
	@Column(name = "freq")
	private int freq;
	@JoinColumn(name = "analysis_id", referencedColumnName = "id", insertable = false, updatable = false)
	@ManyToOne(optional = false, fetch = FetchType.LAZY)
	private Analysis analysis;
	@JoinColumn(name = "termResult_id", referencedColumnName = "id", insertable = false, updatable = false)
	@ManyToOne(optional = false, fetch = FetchType.LAZY)
	private TermResult termResult;

	public AnalysisTermResult() {
	}

	public AnalysisTermResult(AnalysisTermResultPK analysisTermResultPK) {
		this.analysisTermResultPK = analysisTermResultPK;
	}

	public AnalysisTermResult(AnalysisTermResultPK analysisTermResultPK, int freq) {
		this.analysisTermResultPK = analysisTermResultPK;
		this.freq = freq;
	}

	public AnalysisTermResult(int analysisId, int termResultid) {
		this.analysisTermResultPK = new AnalysisTermResultPK(analysisId, termResultid);
	}

	public AnalysisTermResultPK getAnalysisTermResultPK() {
		return analysisTermResultPK;
	}

	public void setAnalysisTermResultPK(AnalysisTermResultPK analysisTermResultPK) {
		this.analysisTermResultPK = analysisTermResultPK;
	}

	public int getFreq() {
		return freq;
	}

	public void setFreq(int freq) {
		this.freq = freq;
	}

	public Analysis getAnalysis() {
		return analysis;
	}

	public void setAnalysis(Analysis analysis) {
		this.analysis = analysis;
	}

	public TermResult getTermResult() {
		return termResult;
	}

	public void setTermResult(TermResult termResult) {
		this.termResult = termResult;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (analysisTermResultPK != null ? analysisTermResultPK.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		if(!(object instanceof AnalysisTermResult)) {
			return false;
		}
		AnalysisTermResult other = (AnalysisTermResult) object;
		if((this.analysisTermResultPK == null && other.analysisTermResultPK != null) || (this.analysisTermResultPK != null && !this.analysisTermResultPK.equals(other.analysisTermResultPK))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "pl.tom.social.dal.entity.AnalysisTermResult[analysisTermResultPK=" + analysisTermResultPK + "]";
	}

}
